{% if footer %}
<footer class="usa-footer">

  {% if footer.last_updated %}
    <div class="grid-container ">
      <p>Last updated: {{ page.last_modified_at | date: '%B %d, %Y at %I:%M %p' }}</p>
    </div>
  {% endif %}

  {% if footer.top %}
    <div class="grid-container usa-footer__return-to-top">
      <a href="{{ footer.top.href | default: '#' }}">{{ footer.top.text | default: 'Return to top' }}</a>
    </div>
  {% endif %}

  {% if footer.links %}
    {% assign footer_links = site.data.navigation[footer.links] | default: footer.links %}
    {% assign _sizes = 'whole half third fourth sixth' | split: ' ' %}
    {% assign _size = footer_links.size | minus: 1 %}
    {% assign _size = _sizes[_size] | default: 'whole' %}
  <div class="usa-footer__primary-section">
    <nav class="usa-footer__nav" aria-label="Footer navigation">
      <ul class="grid-row grid-gap">
        {% for _link in footer_links %}
        <li class="mobile-lg:grid-col-4 desktop:grid-col-auto usa-footer__primary-content">
          <a class="usa-footer__primary-link" href="{% if _link.external == true %}{{ _link.href }}{% else %}{{ _link.href | relative_url }}{% endif %}">
            {{ _link.text }}
          </a>
        </li>
        {% endfor %}
      </ul>
    </nav>
  </div>
  {% endif %}

  {% if footer.logos or footer.heading or footer.contact or footer.edit_page %}
  <div class="usa-footer__secondary-section">
    <div class="grid-container">
      <div class="grid-row grid-gap">
        <div class="usa-footer__logo grid-row mobile-lg:grid-col-6 mobile-lg:grid-gap-2">
          {% if footer.logos %}
            {% for logo in footer.logos -%}
              <div class="mobile-lg:grid-col-auto">
                {% if logo.url %}
                  <a href="{{ logo.url }}">
                {% endif %}
                  <img class="usa-footer__logo-img" src="{% if logo.external %}{{ logo.src }}{% else %}{{ logo.src | relative_url }}{% endif %}" alt="{{ logo.alt }}"{% if logo.width %}width="{{ logo.width }}"{% endif %}{% if logo.height %}height="{{ logo.height }}"{% endif %}>
                {% if logo.url %}
                  </a>
                {% endif %}
              </div>
            {% endfor %}
          {% endif %}

          {% if footer.heading %}
          <div class="mobile-lg:grid-col-auto">
            <h3 class="usa-footer__logo-heading">{{ footer.heading }}</h3>
          </div>
          {% endif %}
        </div>

        {% if footer.contact %}
        <div class="usa-footer__contact-links mobile-lg:grid-col-6">
          {% assign social_links = site.data.footer.contact.social_links %}
          {% if footer.contact.contact_links %}
            <div class="usa-footer__social-links grid-row grid-gap-1">
              <div class="grid-col-auto">
                {% for _link in social_links %}
                  <a class="usa-social-link usa-social-link--{{ _link.type | default: 'generic' }}" href="{% if _link.external == true %}{{ _link.href }}{% else %}{{ _link.href | relative_url }}{% endif %}">
                    <span>{{ _link.text }}</span>
                  </a>
                {% endfor %}
              </div>
            </div>
          {% endif %}
          {% if footer.contact.heading %}
            <h3 class="usa-footer__contact-heading">{{ footer.contact.heading }}</h3>
            {% endif %}
            {% if footer.contact.contact_links %}
              <address class="usa-footer__address">
                {% assign contact_links = site.data.footer.contact.contact_links %}
                <div class="usa-footer__contact-info grid-row grid-gap">
                {% for _link in contact_links %}
                    <div class="grid-col-auto">
                      <a href="{% if _link.external == true %}{{ _link.href }}{% else %}{{ _link.href | relative_url }}{% endif %}">
                        {{ _link.text }}
                      </a>
                    </div>
                {% endfor %}
                </div>
              </address>
          {% endif %}
        {% endif %}
      </div>
      {% if footer.edit_page %}
        {% include components/github-edit.html footer=footer path=page.path %}
      {% endif %}
      </div>
    </div>
  </div>
  {% endif %}

</footer>
{% endif %}
